package com.uek.handler;

import com.uek.pojo.SysUser;
import com.uek.service.UserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class UserController {
    //属性注入
    @Autowired
    UserServiceImpl userService;
    @RequestMapping("/goLogin")
    public String goLogin(){
        return "login";
    }
    //model用来携带数据
    @RequestMapping("/getUser")
    public String getUser(String txtName, String txtPwd, Model model){
        List<SysUser> user = userService.getUser(txtName, txtPwd);
        if(user!=null&&!user.isEmpty()){
            model.addAttribute("txtName",txtName);
            return "index";
        }
        else {
            return "login";
        }
    }
    @RequestMapping("/top")
    public String top(String uname ,Model model){
        model.addAttribute("uname",uname);
        return "top";
    }
    @RequestMapping("/menu")
    public String menu(){
        return "menu";
    }
    @RequestMapping("/welcome")
    public String welcome(){
        return "welcome";
    }

}
